import React, { Component } from 'react'
import Goback from '@/components/Goback/Goback'
import './Practice.less'
import { PracticeApi } from '../../request/api'

export default class Practice extends Component {
    state = {
        testType: "all",
        timuArr: []
    }
    componentDidMount() {
        let MyactionCode = this.props.match.params.actionCode
        PracticeApi({
            actionCode: MyactionCode,
            testType: this.state.testType
        }).then(res => {
            if (res.errCode === 0) {
                let arr = JSON.parse(JSON.stringify(res.data));
                arr.map((item) => {
                    switch (item.key) {
                        case "all":
                            item.key1 = "全部";
                            break;
                        case "qa":
                            item.key1 = "问答题";
                            break;
                        case "code":
                            item.key1 = "编程题";
                            break;
                        case "one":
                            item.key1 = "单选题";
                            break;
                        case "check":
                            item.key1 = "判断题";
                            break;
                        case "many":
                            item.key1 = "多选题";
                            break;
                        default:
                            break;
                    }
                });
                console.log(arr);
                this.setState({
                    timuArr: arr
                })
            }
        })
    }
    render() {
        return (
            <div className="dabox111">
                <div className="box">
                    <div className="lianxi">
                        <div>进入练习模式</div>
                        <div>进入考试模式</div>
                    </div>
                    <div className="danqian">
                        <span>当前学科</span>
                        <span>清除记录</span>
                    </div>
                    <ul>
                        <li className="action">苏成</li>
                        <li>苏成</li>
                        <li>苏成</li>
                        <li>苏成</li>
                    </ul>
                    <div className="danqian">
                        <span>题目类型</span>
                    </div>
                    <ul>
                        {
                            this.state.timuArr.map((item, index) => {
                                return <li key={index}>{item.key1} ({item.value})</li>
                            })
                        }
                    </ul>
                    <div className="danqian">
                        <span>做题数量</span>
                    </div>
                    <ul>
                        <li>苏成</li>
                        <li>苏成</li>
                        <li>苏成</li>
                        <li>苏成</li>
                    </ul>
                </div>


                < Goback />
            </div>
        )
    }
}
